const app = getApp()
var requestApi = require('../../request/requestApi')
var util = require('../../utils/util.js');
Page({
    data: {
        isIphoneX: false,
        screenWidth: '',
        screenHeight: '',
        cardId:'',
        detailInfo: {},



    },


    onLoad: function (option) {
        console.log(option);
        this.data.cardId = option.cardId
        var that = this;
        var wxGetSystemInfo=requestApi.wxGetSystemInfo()
        wxGetSystemInfo().then(res=>{
            var windowWidth = res.windowWidth;
            var windowHeight = res.windowHeight;
            if (util.systemInfoToPhoneHeightIsX(res)=='X') {
                that.setData({
                    isIphoneX: true,
                })
            } else if(util.systemInfoToPhoneHeightIsX(res)=='N'){
                that.setData({
                    isIphoneX: false,
                })
            }
            that.setData({
                screenWidth: windowWidth,
                screenHeight:windowHeight,
            })
        })

        this.configDataFromNetwork();
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {


    },
    configDataFromNetwork:function () {
        var that=this;
        requestApi.kukeGetCardDetail(this.data.cardId).then(res=>{
            console.log('configDataFromNetwork-----------------')
            console.log(res)
            var listNetData = res.data.data.card;

            that.data.detailInfo.cardImg = listNetData.img;
            that.data.detailInfo.subTitle = listNetData.subtitle;
            that.data.detailInfo.cardTitle = listNetData.title;
            that.data.detailInfo.cardId = listNetData.card_id;
            that.data.detailInfo.cardDetail = listNetData.introduce;
            that.data.detailInfo.itemCode = listNetData.item_code;
            that.data.detailInfo.workId = listNetData.work_id;
            that.setData({ detailInfo: that.data.detailInfo })
        })
    },
    clickToNavigation:function (e) {
        // console.log(e)
        if (e.currentTarget.dataset.type == 'back'){
            wx.navigateBack({
                //保留当前页面，跳转到应用内的某个页面（最多打开5个页面，之后按钮就没有响应的）
                delta:1
            })
        }
    }
})
